package com.kavin.rgb;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import java.io.File;

public class MainActivity extends CheckPermissionActivity {

    private ImageView image;
    private ImageView image2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        image = findViewById(R.id.image);
        image2 = findViewById(R.id.image2);

    }

    @Override
    void onRequestPermissionsResultListener(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults, boolean noPermission) {

    }


    public void onClick(View view) {
        BitmapUtils.greyColor(image);
        BitmapUtils.reversalColor(image2);
    }


    public void onClick2(View view) {
        Bitmap bitmap = ((BitmapDrawable) image.getDrawable()).getBitmap();
        String path = getExternalCacheDir().getAbsolutePath() + File.separator + "a.png";
        boolean success = BitmapUtils.saveBitmap(path, bitmap);
        Toast.makeText(this, success + path, Toast.LENGTH_LONG).show();
    }
}
